package com.miniblog.gateway.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 路径：com.miniblog.gateway.config.UriKeyResolver.java
 * 类名：UriKeyResolver.java
 * 功能：网关限流过滤器
 * 备注：
 * 创建人：typ
 * 创建时间：2020/01/02 21:46
 */
@Configuration
public class UriKeyResolver implements KeyResolver {

    /**
     * 方法名：fallback
     * 功能：根据请求的 uri 限流
     * 描述：
     * 创建人：typ
     * 创建时间：2019/11/12 21:26
     */
    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        return Mono.just(exchange.getRequest().getURI().getPath());
    }

}
